// var arr = new Array(2);
// console.log(arr.length)
// console.log(arr)

// var arr = Array(3);
// // 等同于
// var arr = new Array(4);


/** 数组链式使用*/
var users = [
    { name: 'tom', email: 'tom@example.com' },
    { name: 'peter', email: 'peter@example.com' }
];

//map映射字段 整个对象替换
var usernews = users.map(function (user) {
    var usernew = {};
    usernew.a = user.name;
    usernew.b = user.email;
    return usernew;
})
console.log(usernews);

//map映射字段 取某个字段列
var usernewsMap = usernews.map(function (usernew) {
    return usernew.b;
});
console.log(usernewsMap);

//filter过滤条件
var userfilter = usernewsMap.filter(function (b) {
    return /^t/.test(b);
});
console.log(userfilter);

//forEach循环
userfilter.forEach(function (b) {
    console.log(b);
});
  // "tom@example.com"
